home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00110_Script_Generate numPages-pictures in each topic < prev    next >
Text File  |  1996-03-28  |  3KB  |  103 lines

  1. -- --------------------------------------------------------------
  2. -- Handler generateNumPagesPerTopic puts info into the field
  3. -- "numPages per Topic" which contains the number of pages in each
  4. -- browserTopic.
  5.  
  6. -- NOTE: this handler assumes every topic has an article. Before this
  7. -- handler is run, run checkArticleCasts first to get a list of all
  8. -- topics that do not have articles. Correct those errors, and then
  9. -- run this handler.
  10.  
  11.  
  12. on generateNumPagesPerTopic numLinesPerBrowserTopic
  13.   if voidP(numLinesPerBrowserTopic) then
  14.     set numLinesPerBrowserTopic = 1
  15.   end if
  16.   
  17.   set browserTopics = field "browserTopics"
  18.   set numLines = the number of lines in browserTopics
  19.   set numTopics = (numLines - (numLines/numLinesPerBrowserTopic -1)) / numLinesPerBrowserTopic
  20.   
  21.   put EMPTY into field "numPages per Topic" 
  22.   
  23.   set curLine = 1
  24.   
  25.   -- go through the browser topics one by one
  26.   repeat while (curLine <= numLines)
  27.     set curTopic = line curLine of browserTopics
  28.     set pageIndex = 1
  29.     
  30.     put "checking" && curTopic
  31.     
  32.     if (curTopic <> EMPTY) then
  33.       -- get num pages
  34.       set pageIndex = getNumPropertyGenerate(curTopic, "text")
  35.       put curTopic & ":" & string(pageIndex-1) & RETURN after field "numPages per Topic"
  36.     end if -- curTopic <> EMPTY
  37.     
  38.     set curLine = getNextTopicStartLine(curLine, numLinesPerBrowserTopic) 
  39.   end repeat -- going through the topics
  40. end
  41.  
  42. -- --------------------------------------------------------------
  43. -- Handler getNumPropertyGenerate
  44.  
  45. on getNumPropertyGenerate whichTopic, type
  46.   set index = 1
  47.   set continue = TRUE
  48.   
  49.   repeat while continue
  50.     set articleCast = the number of cast (whichTopic && type & string(index))
  51.     
  52.     if (articleCast = -1) then
  53.       set continue = FALSE
  54.       return index
  55.     else 
  56.       set index = index + 1
  57.     end if
  58.   end repeat
  59. end
  60.  
  61. -- --------------------------------------------------------------
  62. -- Handler generateNumPicturesPerTopic puts info into the field
  63. -- "numPictures per Topic" which contains the number of pictures in each
  64. -- browserTopic..
  65.  
  66.  
  67. on generateNumPicturesPerTopic numLinesPerBrowserTopic
  68.   if voidP(numLinesPerBrowserTopic) then
  69.     set numLinesPerBrowserTopic = 1
  70.   end if
  71.   
  72.   set browserTopics = field "browserTopics"
  73.   set numLines = the number of lines in browserTopics
  74.   set numTopics = (numLines - (numLines/numLinesPerBrowserTopic -1)) / numLinesPerBrowserTopic
  75.   
  76.   put EMPTY into field "numPictures per Topic" 
  77.   
  78.   set curLine = 1
  79.   
  80.   -- go through the browser topics one by one
  81.   repeat while (curLine <= numLines)
  82.     set curTopic = line curLine of browserTopics
  83.     set index = 1
  84.     
  85.     put "checking" && curTopic
  86.     
  87.     if (curTopic <> EMPTY) then
  88.       -- get num pages
  89.       set index = getNumPropertyGenerate(curTopic, "picture")
  90.       put curTopic & ":" & string(index-1) & RETURN after field "numPictures per Topic"
  91.     end if -- curTopic <> EMPTY
  92.     
  93.     set curLine = getNextTopicStartLine(curLine, numLinesPerBrowserTopic) 
  94.   end repeat -- going through the topics
  95. end
  96.  
  97. on generateAll
  98.   setUpCastNumbersFields
  99.   generateNumPagesPerTopic(1)
  100.   generateNumPicturesPerTopic(1)
  101.   saveMovie
  102.   quit
  103. end